class Solution:
    def reverse(self, x: int) -> int:
        x = list(str(x))
        if x[0] == "-":
            ret =  -int("".join(x[:0:-1]))
        else:
            ret = int("".join(x[::-1]))
        if -2**31<= ret <= 2**31-1:
            return ret
        return 0
print(Solution().reverse(1))
print(Solution().reverse(2))
print(Solution().reverse(3))
print(Solution().reverse(123))
print(Solution().reverse(-123))
print(Solution().reverse(-1230))
print(Solution().reverse(-12030))
print(Solution().reverse(-2030))